/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;
import model.UltimoNumero;
import org.hibernate.Session;
import org.hibernate.Transaction;
import util.HibernateUtil;

/**
 *
 * @author Fran
 */

public class UltimoNumeroDAO {
    
    public UltimoNumeroDAO(){
        
       session = HibernateUtil.getSessionFactory().openSession();
       
    }
    
    private Session session;
    
    public UltimoNumero findUltNumero(String id)
    {
        
        return (UltimoNumero) session.load(UltimoNumero.class, id);
        
    }
    
    
    public void update(UltimoNumero ultimonumero)
    {
        Transaction t = session.beginTransaction();
        session.merge(ultimonumero);
        t.commit();
    }
    
    public void insert(UltimoNumero ultimonumero)
    {
        Transaction t = session.beginTransaction();
        session.save(ultimonumero);
        t.commit();
    }
}
